using System;
using TMPro;
using UnityEngine.Serialization;

namespace UnityEngine.UI.Extensions
{
    public class UICellRect : FancyScrollRectCell<UICellData, UIContextRect>
    {
        public TextMeshProUGUI Message;

        public Action<int> OnUpdateCell;
        public Action<float, float> OnUpdatePostion;

        public override void UpdateContent(UICellData cellData)
        {
            if (OnUpdateCell != null)
            {
                OnUpdateCell(cellData.Index);
            }

            Message.text = cellData.Index.ToString();
        }

        protected override void UpdatePosition(float normalizedPosition, float localPosition)
        {
            base.UpdatePosition(normalizedPosition, localPosition);

            if (OnUpdatePostion != null)
            {
                OnUpdatePostion(normalizedPosition, localPosition);
            }
        }
    }
}